/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package levels;

import Actors.ActorManager;
import Actors.BlockadeActor;
import Actors.EnemyActor;
import graphics.AbstractRenderer;
import java.net.URL;
import resources.images.ResourceStub;
import stealth.Main;

/**
 *
 * @author Joshua
 */
public class TestLevelSkeleton extends Level {

    BlockadeActor blackHole;
    EnemyActor[] enemies = new EnemyActor[10];

    @Override
    public void loadSinglePlayerGame() {
        //blackHole = new BlockadeActor(300, 256, 256);
    }

    @Override
    public void loadTwoPlayerGame() {
        //blackHole = new BlockadeActor(300, 256, 256);
    }

    @Override
    public void addRendereringInstructions(AbstractRenderer r) {
        //r.addRenderInstruction(blackHole.render());
        for (EnemyActor a : enemies) {
            if (a != null) {
                r.addRenderInstruction(a.render());
            }
        }
    }

    @Override
    protected URL getLevelBackgroundImage() {
        return ResourceStub.class.getResource("star_back.gif");
    }
    int wait = Main.game.getFPS();

    @Override
    public void update() {
        if (Math.random() < .1) {
            for (int i = 0; i < enemies.length; i++) {
                if (wait == 0) {
                    wait = Main.game.getFPS();
                    if (enemies[i] == null) {
                        enemies[i] = new EnemyActor();
                        ActorManager.addToCollisionDetect(enemies[i]);
                    } else if (enemies[i].die) {
                        ActorManager.removeFromCollisionDetection(enemies[i]);
                        enemies[i] = new EnemyActor();
                        ActorManager.addToCollisionDetect(enemies[i]);
                    }
                } else {
                    wait--;
                }
            }
        }
        for (EnemyActor a : enemies) {
            if (a != null && !a.die) {
                a.act();
            }
        }
    }
}
